package com.xiaoc.bulldozer.common.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.xiaoc.bulldozer.common.dao.AccountMapper;
import com.xiaoc.bulldozer.common.dao.PhoneLocationMapper;
import com.xiaoc.bulldozer.common.dto.AccountDto;
import com.xiaoc.bulldozer.common.dto.AccountQueryDto;
import com.xiaoc.bulldozer.common.model.Account;
import com.xiaoc.bulldozer.common.service.AccountService;
import com.xiaoc.bulldozer.common.service.cache.CommonConfigCacheService;

/**
 * Account Service 实现类
 *
 * @author Danfo Yam
 * @date 2018-08-24 15:47:58
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {

    private Logger logger = LoggerFactory.getLogger(AccountServiceImpl.class);

    @Resource
    private AccountMapper accountMapper;

    @Resource
    private PhoneLocationMapper phoneLocationMapper;

    @Resource(name = "commonConfigService")
    private CommonConfigCacheService commonConfigService;


    @Override
    public Account getAccountById(Integer id) {
        return accountMapper.getAccountById(id);
    }

    @Override
    public List<AccountDto> getAccountList(AccountQueryDto accountQueryDto) {
        return accountMapper.getAccountList(accountQueryDto);
    }

    @Override
    public Integer getAccountCount(AccountQueryDto accountQueryDto) {
        return accountMapper.getAccountCount(accountQueryDto);
    }

    @Override
    public List<Account> getAllAccountList() {
        return accountMapper.getAllAccountList();
    }

    @Override
    public void save(Account account) {
        accountMapper.save(account);
    }

    @Override
    public void update(Account account) {
        account.setUpdateTime(System.currentTimeMillis());
        accountMapper.update(account);
    }

    @Override
    public void deleteById(Integer id) {
        accountMapper.deleteById(id);
    }

    @Override
    public Account getAccountByUserId(Integer userId) {
        return accountMapper.getAccountByUserId(userId);
    }

    @Override
    public Account getAccountByPhoneNumber(String phoneNumber) {
        return accountMapper.getAccountByPhoneNumber(phoneNumber);
    }

    @Override
    public List<Account> getAccountListByOwnerId(AccountQueryDto accountQueryDto) {
        return accountMapper.getAccountListByOwnerId(accountQueryDto);
    }

    @Override
    public Integer getAccountCountByOwnerId(Integer id) {
        return accountMapper.getAccountCountByOwnerId(id);
    }

    @Override
    public Integer getRegisterSuccessCountByParentAccountId(Integer parentAccountId) {
        return accountMapper.getRegisterSuccessCountByParentAccountId(parentAccountId);
    }

    @Override
    public Integer getRegisterSuccessCountByType() {
        return accountMapper.getRegisterSuccessCountByType();
    }

}
